package gov.tax.rti.base.filter;

import gov.tax.rti.core.ext.filter.RtiCoreDelegatingFilterProxy;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bstek.bdf2.core.context.ContextHolder;

/**
 * 扩展DelegatingFilterProxy
 * @author steven.zheng@bstek.com
 * 
 */
public class RtiDelegatingFilterProxy extends RtiCoreDelegatingFilterProxy {
	
    protected void invokeDelegate(Filter delegate, ServletRequest request, ServletResponse response, FilterChain filterChain)
        throws ServletException, IOException
    {
		ContextHolder.setHttpRequestResponseHolder((HttpServletRequest)request, (HttpServletResponse)response);
		try {
			super.invokeDelegate(delegate, request, response, filterChain);
		}finally{
    		ContextHolder.clean();
	    }
    }
    
    public void destroy()
    {
    	try {
    		super.destroy();
    	}finally{
    		ContextHolder.clean();
	    }
    }
	
}
